home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE23 / CLINIC / CALLERU.PAS < prev    next >
Pascal/Delphi Source File  |  1997-04-17  |  1KB  |  63 lines

  1. unit CallerU;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Button3: TButton;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure Button2Click(Sender: TObject);
  16.     procedure Button3Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   published
  22.     procedure MyRoutine(const Msg: string);
  23.   end;
  24.  
  25.   TCustomProc = procedure (const Msg: string) of object;
  26.  
  27. var
  28.   Form1: TForm1;
  29.  
  30. implementation
  31.  
  32. {$R *.DFM}
  33.  
  34. procedure TForm1.MyRoutine(const Msg: string);
  35. begin
  36.   MessageDlg(Msg, mtInformation, [mbOk], 0)
  37. end;
  38.  
  39. procedure TForm1.Button1Click(Sender: TObject);
  40. begin
  41.   ShowMessage('A button was pushed... or was it?')
  42. end;
  43.  
  44. procedure TForm1.Button2Click(Sender: TObject);
  45. var
  46.   Proc: TNotifyEvent;
  47. begin
  48.   @Proc := MethodAddress('Button1Click');
  49.   if Assigned(Proc) then
  50.     Proc(nil);
  51. end;
  52.  
  53. procedure TForm1.Button3Click(Sender: TObject);
  54. var
  55.   Proc: TCustomProc;
  56. begin
  57.   @Proc := Self.MethodAddress('MyRoutine');
  58.   if Assigned(Proc) then
  59.     Proc('Hello world');
  60. end;
  61.  
  62. end.
  63.